package com.ruoyi.web.controller.system.fuw;

import java.util.List;

import com.ruoyi.fuw.service.IFuwCommsOrdersService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fuw.domain.FuwCommsOrders;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品订单信息Controller
 * 
 * @author ruoyi
 * @date 2021-10-30
 */
@RestController
@RequestMapping("/fuw/orders")
public class FuwCommsOrdersController extends BaseController
{
    @Autowired
    private IFuwCommsOrdersService fuwCommsOrdersService;

    /**
     * 查询商品订单信息列表
     */
    @PreAuthorize("@ss.hasPermi('fuw:orders:list')")
    @GetMapping("/list")
    public TableDataInfo list(FuwCommsOrders fuwCommsOrders)
    {
        startPage();
        List<FuwCommsOrders> list = fuwCommsOrdersService.selectFuwCommsOrdersList(fuwCommsOrders);
        return getDataTable(list);
    }

    /**
     * 导出商品订单信息列表
     */
    @PreAuthorize("@ss.hasPermi('fuw:orders:export')")
    @Log(title = "商品订单信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FuwCommsOrders fuwCommsOrders)
    {
        List<FuwCommsOrders> list = fuwCommsOrdersService.selectFuwCommsOrdersList(fuwCommsOrders);
        ExcelUtil<FuwCommsOrders> util = new ExcelUtil<FuwCommsOrders>(FuwCommsOrders.class);
        return util.exportExcel(list, "商品订单信息数据");
    }

    /**
     * 获取商品订单信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('fuw:orders:query')")
    @GetMapping(value = "/{uId}")
    public AjaxResult getInfo(@PathVariable("uId") Long uId)
    {
        return AjaxResult.success(fuwCommsOrdersService.selectFuwCommsOrdersByUId(uId));
    }

    /**
     * 新增商品订单信息
     */
    @PreAuthorize("@ss.hasPermi('fuw:orders:add')")
    @Log(title = "商品订单信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FuwCommsOrders fuwCommsOrders)
    {
        return toAjax(fuwCommsOrdersService.insertFuwCommsOrders(fuwCommsOrders));
    }

    /**
     * 修改商品订单信息
     */
    @PreAuthorize("@ss.hasPermi('fuw:orders:edit')")
    @Log(title = "商品订单信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FuwCommsOrders fuwCommsOrders)
    {
        return toAjax(fuwCommsOrdersService.updateFuwCommsOrders(fuwCommsOrders));
    }

    /**
     * 删除商品订单信息
     */
    @PreAuthorize("@ss.hasPermi('fuw:orders:remove')")
    @Log(title = "商品订单信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uIds}")
    public AjaxResult remove(@PathVariable Long[] uIds)
    {
        return toAjax(fuwCommsOrdersService.deleteFuwCommsOrdersByUIds(uIds));
    }
}
